# Contributor: grharry
# Maintainer:
pkgname=coova-chilli
pkgver=1.6
pkgrel=1
pkgdesc="CoovaChilli is an open source access controller for wireless LAN"
url="http://www.coova.org/"
arch="all"
license="GPL-3.0-or-later"
makedepends="perl openssl1.1-compat-dev autoconf automake libtool curl-dev
	linux-headers gengetopt-dev"
install="$pkgname.pre-install"
pkgusers="chilli"
pkggroups="chilli"
subpackages="$pkgname-doc $pkgname-dev $pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/coova/coova-chilli/archive/$pkgver.tar.gz
	chilli.initd
	chilli.confd
	"
options="suid"

prepare() {
	default_prepare
	sed -i 's/-Werror//g' src/Makefile.am
	sed -i 's%(localstatedir)/run%(localstatedir)%' src/Makefile.am
	libtoolize --force \
		&& autoreconf -vif
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var/run/chilli \
		--libdir=/usr/lib \
		--sysconfdir=/etc \
		--with-openssl \
		--with-poll \
		--enable-binstatusfile \
		--enable-statusfile \
		--enable-chillixml \
		--enable-ipwhitelist \
		--enable-redirinject \
		--enable-redirdnsreq \
		--enable-redirinject \
		--enable-debug \
		--enable-debug2 \
		--enable-miniportal \
		--enable-sessgarden \
		--enable-shared \
		--enable-chilliredir \
		--enable-chilliscript \
		--enable-layer3 \
		--enable-dhcpopt \
		--enable-largelimits
	export CFLAGS="$CFLAGS -Wno-error=unused-but-set-variable"
	make -j1
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install

	install -Dm755 "$srcdir"/chilli.initd "$pkgdir"/etc/init.d/chilli
	install -Dm644 "$srcdir"/chilli.confd "$pkgdir"/etc/conf.d/chilli
	install -d -o $pkgusers -g $pkggroups "$pkgdir"/var/run/chilli
}

sha512sums="0b6e26445ebe93cde233475d0b2401e60007362310f7464989713da3c58e22eb8e0dff1584d259e5be4090aed89e2948e26d2e7d3c739df990d068a77613b616  coova-chilli-1.6.tar.gz
eb0feda33f74256cedd4987d22427c1575f4de08636ff02c16cb4f6710a54dce0d23410d56e961727d4e78f5f4fb0a7848505215e5c91518301d1e81b589ecde  chilli.initd
840712709974d5a3567e0a14cb05d7e394bf73ac06c0ea865c00351d916f794ec3e70bfbc9255afd419aeceaae3f4b0cbf7e770ccd23af1e677e15821c1690cf  chilli.confd"
